import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, OneToMany } from 'typeorm';
import { BaseEntity } from './base.entity';

@Entity()
export class Menu extends BaseEntity {

  @Column({ length: 50 })
  name!: string;

  @Column({ nullable: true, length: 200 })
  path!: string;

  @Column({ default: 0 })
  sort!: number;

  // 显式指定列类型
  @Column({ 
    nullable: true, 
    name: 'parent_id',
    type: 'int' // 明确指定为整数类型
  })
  parentId?: number | null;

  // @ManyToOne(() => Menu, menu => menu.children, { onDelete: 'CASCADE' })
  // parent!: Menu | null;

  // @OneToMany(() => Menu, menu => menu.parent)
  // children!: Menu[];
}